<?php

namespace App\Console\Commands\Tasks;
use Illuminate\Console\Command;
use App\Http\Controllers\Common\TaskController;

class ConnectReturnGift extends Command
{
    //命令名
    protected $signature = 'task:connect_return_gift';

    //命令描述：每分钟检查是否有未开启的礼物盒子
    protected $description = 'connectReturnGift';

    public function __construct()
    {
        parent::__construct();
    }

    //业务处理
    public function handle()
    {
        $time = date('Y-m-d H:i:s',time());
        //获取24小时01分钟之前未处理的关系
        $relation = app('model_connect_apply')->where('status',0)->where('expire_time','<=', $time)->get();
        
        $relation = empty($relation)?[]:$relation->toArray();
        var_dump($relation);
        foreach ($relation as $k=>$v){
            app('model_connect_apply')->refuseApply($v);
        }
    }

}